﻿using AbpVnext_Module.Dto;
using AbpVnext_Module.Iservice;
using AbpVnext_Module.Service;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace AbpVnext_Module.Controllers
{
    [Route("api/ProductImagegProxy/[action]")]
    [ApiController]
    public class ProductImageController : AbpController , IProductImageService
    {

        public ProductImageController()
        {

        }

        /// <summary>
        /// ProductImageService
        /// </summary>
        public IProductImageService ProductImageService { get; set; }

        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="pagedAndSortedResultRequestDto"></param>
        /// <returns></returns>
        // GET: api/<ProductImageController>
        [HttpGet]
        public async Task<PagedResultDto<ProductImageDto>> GetListAsyc([FromQuery] ProductImagePageDto pagedAndSortedResultRequestDto)
        {
            return await ProductImageService.GetListAsync(pagedAndSortedResultRequestDto);
        }


        // GET api/<ProductImageController>/5
        [HttpGet("{id}")]
        public async Task<ProductImageDto> Get(int id)
        {
            return await ProductImageService.GetAsync(id);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="productImageCreateDto"></param>
        /// <returns></returns>
        // POST api/<ProductImageController>
        [HttpPost]
        public async Task<ProductImageDto> CreateAsync([FromBody] ProductImageCreateDto productImageCreateDto)
        {
            //测试事务
            {
                return await ProductImageService.CreateAsync(productImageCreateDto);
                //try
                //{
                //    return await ProductImageService.CreateAsync(productImageCreateDto);
                //}
                //catch (Exception ex)
                //{

                //}
                //return await ProductImageService.CreateAsync(productImageCreateDto);
                //return new ProductImageDto();
                //return null;
            }
            //测试事务
            {
                //return await TestOrderAppService.CreateAsync(productImageCreateDto);
            }
        }

        // PUT api/<ProductImageController>/5
        [HttpPut("{id}")]
        public async Task<ProductImageDto> UpdateAsync(int id, [FromBody] ProductImageUpdateDto productImageUpdateDto)
        {
            return await ProductImageService.UpdateAsync(id, productImageUpdateDto);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        // DELETE api/<ProductImageController>/5
        [HttpDelete("{id}")]
        public async Task<string> DeleteAsync(int id)
        {
            await ProductImageService.DeleteAsync(id);
            return "删除成功";
        }

        [HttpGet]
        public async Task<ProductImageDto> GetAsync(int id)
        {
            return await ProductImageService.GetAsync(id);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<PagedResultDto<ProductImageDto>> GetListAsync(ProductImagePageDto input)
        {
            throw new NotImplementedException();
        }

        [HttpGet]
        Task IDeleteAppService<int>.DeleteAsync(int id)
        {
            throw new NotImplementedException();
        }
    }
}
